package com.jhhc.Http;

import com.jhhc.Http.Pojo.RequestPojo;
import com.jhhc.Http.Service.GetUrlService;
import com.jhhc.Http.ServiceImpl.GetUrlServiceImpl;
import com.jhhc.utils.JsonResult;
import dm.jdbc.filter.stat.json.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Api(value="HttpController",tags={"合溪水库服务"})
@RestController
public class HttpController {

    @Autowired
    private  GetUrlServiceImpl getUrlServiceImpl;


    // 查询实况数据
    @ApiOperation("查询Token")
    @RequestMapping(value = "GetTokne", headers = "Accept=application/json", method = RequestMethod.GET)
    public void getToken(){

        String Url ="https://sgpt.zjwater.com/service/v2/auth/generateToken/cad57a15";
        JSONObject message = null;
        try {
            message = GetUrlService.getTokenUrl(Url);
            String url = String.valueOf(message.getMap().get("url"));
            String token = String.valueOf(message.getMap().get("token"));

            System.out.println(url);
            System.out.println(token);
        } catch (Exception e) {
            e.printStackTrace();
        }



    }

    // 查询实况数据
    @ApiOperation("查询实况数据")
    @RequestMapping(value = "GetData", headers = "Accept=application/json", method = RequestMethod.GET)
    public JsonResult GetData_GET(){
        JsonResult jsonResult = new JsonResult();
        try {
            getUrlServiceImpl.getRSVRdata();
            getUrlServiceImpl.getPPTNdata();
        } catch (Exception e) {
            e.printStackTrace();
        }
        jsonResult.setStatusCode(200);
        jsonResult.setSucceeded(true);
     //

        return jsonResult;
    }

}
